<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro" %>
<shiro:lacksPermission name="production:look">没有查询此模块权限。。。</shiro:lacksPermission>

<shiro:hasPermission name="production:look">
    <!DOCTYPE HTML>
    <html>
    <head>
        <meta charset="UTF-8">

        <link rel="stylesheet" type="text/css"
              href="easyui/themes/bootstrap/easyui.css">
        <script type="text/javascript" src="easyui/jquery.min.js"></script>
        <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
        <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
        <script type="text/javascript" src="easyui/locale/easyui-lang-zh_CN.js"></script>
        <script type="text/javascript" src="myjs/production.js"></script>
        <script src="js/yangshi.js"></script>
        <script src="myjs/path.js"></script>
    </head>
    <body class="easyui-layout">

    <div id="tb" style="height: auto">
        <shiro:hasPermission name="production:create">
            <span id="zongbu">
            <a href="javascript:void(0)" class="easyui-linkbutton"
               data-options="iconCls:'icon-add',plain:true" onclick="openWindow(1)">新增</a>
                </span>

            <span id="xiaji">
        <a href="javascript:void(0)" class="easyui-linkbutton"
           data-options="iconCls:'icon-add',plain:true" onclick="openDownWindow(0)">新增</a>
            </span>
        </shiro:hasPermission>
        <shiro:hasPermission name="production:del">
            <a href="javascript:void(0)" class="easyui-linkbutton"
               data-options="iconCls:'icon-remove',plain:true" id="delt"
               onclick="shanchu()">删除</a>
        </shiro:hasPermission>
        <shiro:hasPermission name="production:update">
        <span id="zongbuxiugai">
            <a href="javascript:void(0)" class="easyui-linkbutton"
               iconCls="icon-edit" plain="true" onclick="openWindow(2)">修改</a></span>

            <span id="xiajixiugai"> <a href="javascript:void(0)" class="easyui-linkbutton"
                                       iconCls="icon-edit" plain="true" onclick="openDownWindow(2)">修改</a></span>
        </shiro:hasPermission>
        <shiro:hasPermission name="production:ty">
            <a href="javascript:void(0)" class="easyui-linkbutton"
               iconCls="icon-no" plain="true" onclick="tingyong(1)">停用产品</a>
        </shiro:hasPermission>
        <shiro:hasPermission name="production:hf">
            <a href="javascript:void(0)" class="easyui-linkbutton"
               iconCls="icon-reload" plain="true" onclick="tingyong(0)">恢复产品</a>
        </shiro:hasPermission>
        <shiro:hasPermission name="production:create1">
            <button id='' iconCls="icon-redo" class="easyui-linkbutton" onclick="$('#daoExcel').window('open')">批量导入</button>
        </shiro:hasPermission>


        <input id="ss" class="easyui-searchbox" style="width:300px"
               data-options="searcher:qq,prompt:'请输入款号关键词',menu:'#mm'"></input>

        <div id="mm" style="width:120px">
            <div data-options="name:'-1'">全部产品</div>
            <div data-options="name:'0',iconCls:'icon-ok'">在产/在售</div>
            <div data-options="name:'1',iconCls:'icon-no'">停产/停售</div>
        </div>
        <a iconCls="icon-save" class="easyui-linkbutton" type="button" onclick="downExcel()">导出Excel</a>
        <script type="text/javascript">
            function qq(value, name) {
                //value是搜索框里的值,name是选择框里的值
                $("#dg").datagrid({
                    url: path + '/production/findall.do',
                    queryParams: {
                        product: value,
                        state: name
                    }
                });
            }
        </script>
            <%--     <a id='' href="#" class="easyui-linkbutton" iconCls="icon-print" onclick="opendp()"
                    plain="true">打印</a>--%>


    </div>
    <table id="dg" class="easyui-datagrid">

    </table>
        <%--导入窗口--%>
    <div id="daoExcel" class="easyui-dialog" title="批量导入商品信息"
         data-options="buttons:'#bs', modal:true,closed:true,collapsible:false,iconCls:'icon-save',minimizable:false,maximizable:false"
         style="padding: 15px;">

        供应商：<input id="gongyingshang"/>
        <div style="height: 10px"></div>
        <input type="file" id="excel" style="width: 250px"> <a
            href="javascript:void(0)" onclick="downloadMuban()">下载导入模板</a>
        <div style="height: 10px"></div>
        <div style="margin: 0 auto; width: 120px;" id="bs">
            <button id="daoru" onclick="daoruExcel()" href=""
                    class="easyui-linkbutton" data-options="iconCls:'icon-save' ">导入
            </button>
            <button id="no" onclick="$('#daoExcel').window('close')"
                    class="easyui-linkbutton" data-options="iconCls:'icon-no'">取消
            </button>
        </div>
    </div>
        <%--新增入口--%>
    <div id="addwindow" class="easyui-dialog"
         data-options="buttons:'#bb', modal:true,closed:true,collapsible:false,iconCls:'icon-save',minimizable:false,maximizable:false"
         style="padding: 15px;width:550px;height: 490px">
        <input id="id" type="hidden">
        <div id="tishi" style="color: red;margin: 0 auto;width: 310px;"></div>
        <table>
            <tr>
                <td align="right">款号：<span style="color:red">*</span></td>
                <td align="left"><input id="kuanhao" class="easyui-textbox" style="width:160px;"
                                        data-options="prompt:'请输入款号'"><br><span style="font-size: 12px;color: red;"
                                                                                id="kuanhaotest"></span>
                </td>
                <td align="right">款名：<span style="color:red">*</span></td>
                <td align="left"><input id="kuanming" class="easyui-textbox" style="width:160px;"
                                        data-options="prompt:'请输入款号名称'"><br><span style="font-size: 12px;color: red;"
                                                                                  id="kuanmingtest"></span>
                </td>
            </tr>
            <tr>
                <td align="right">铭牌价：<span style="color:red">*</span></td>
                <td><input id="mingpaijia" class="easyui-numberbox" style="width:160px;" type="text" precision="2"
                           data-options="min:0,prompt:'请输入铭牌价格'"><br><span style="font-size: 12px;color: red;"
                                                                           id="mingpaijiatest"></span></td>
                <td align="right">款式：<span style="color:red">*</span></td>
                <td><input id="kuanshi" class="easyui-combobox" style="width:160px;" data-options="valueField: 'kuanshi',
                    textField: 'kuanshi'"><br><span style="font-size: 12px;color: red;"
                                                    id="kuanshitest"></span></td>
            </tr>
            <tr>
                <td align="right">品牌：<span style="color:red">*</span></td>
                <td><input id="pinpai" class="easyui-combobox" style="width:160px;" data-options=" valueField: 'pinpai',
                    textField: 'pinpai'"><br><span style="font-size: 12px;color: red;"
                                                   id="pinpaitest"></span></td>
                <td align="right">款型：<span style="color:red">*</span></td>
                <td><input id="kuanxing" class="easyui-combobox" style="width:160px;" data-options=" valueField: 'kuanxing',
                    textField: 'kuanxing'"><br><span style="font-size: 12px;color: red;"
                                                     id="kuanxingtest"></span></td>
            </tr>

            <tr>
                <td align="right">大类：<span style="color:red">*</span></td>
                <td><input id="dalei" class="easyui-combobox" style="width:160px;" data-options=" valueField: 'dalei',
                    textField: 'dalei'"><br><span style="font-size: 12px;color: red;"
                                                  id="daleitest"></span>
                </td>

                <td align="right">小类：<span style="color:red">*</span></td>
                <td><input id="xiaolei" class="easyui-combobox" style="width:160px;" data-options=" valueField: 'xiaolei',
                    textField: 'xiaolei'"><br><span style="font-size: 12px;color: red;"
                                                    id="xiaoleitest"></span>
                </td>
            </tr>


            <tr>
                <td align="right">供应商：<span style="color:red">*</span></td>
                <td><input id="gongyings" class="easyui-combobox" style="width:160px;" data-options=" valueField: 'id',
                    textField: 'gname',onHidePanel: function() {
                         var valueField = $(this).combobox('options').valueField;
                    var val = $(this).combobox('getValue');  //当前combobox的值
                    var allData = $(this).combobox('getData');   //获取combobox所有数据
                    var result = true;      //为true说明输入的值在下拉框数据中不存在
                    for (var i = 0; i < allData.length; i++) {
                    if (val == allData[i][valueField]) {
                    result = false;
                    }
                    }
                    if (result) {
                    $(this).combobox('clear');
                    }
                    }"><br><span style="font-size: 12px;color: red;"
                                 id="gongyingstest"></span></td>
                <td align="right">性别：<span style="color:red">*</span></td>
                <td><input id="xingbie" class="easyui-combobox" style="width:160px;" data-options=" valueField: 'sex',
                    textField: 'sex'"><br><span style="font-size: 12px;color: red;"
                                                id="xingbietest"></span></td>
            </tr>
            <tr>
                <td align="right">年份：</td>
                <td><select id="year" class="easyui-combobox" panelHeight="auto" editable="false" style="width:160px;">
                    <option>2015</option>
                    <option>2016</option>
                    <option>2017</option>
                    <option>2018</option>
                    <option>2019</option>
                    <option>2020</option>
                </select>
                </td>
                <td align="right">季节：<span style="color:red">*</span></td>
                    <%--<td><input id="jijie" class="easyui-combobox" style="width:160px;" data-options="valueField: 'jijie',
                        textField: 'jijie'"><br><span style="font-size: 12px;color: red;"
                                                      id="jijietest"></span></td>--%>
                <td><select id="jijie" class="easyui-combobox" panelHeight="auto" editable="false" style="width:160px;">
                    <option>春季</option>
                    <option>夏季</option>
                    <option>秋季</option>
                    <option>冬季</option>
                </select>
                    <span style="font-size: 12px;color: red;"
                          id="jijietest"></span></td>
            </tr>
            <tr>
                <td align="right">安全级别：<span style="color:red">*</span></td>
                <td><input id="anquanjibie" class="easyui-combobox" style="width:160px;" data-options=" valueField: 'anquanjibie',
                    textField: 'anquanjibie'"><br><span style="font-size: 12px;color: red;"
                                                        id="anquanjibietest"></span></td>
                <td align="right">执行标准：<span style="color:red">*</span></td>
                <td><input id="zhixingbiaozhun" class="easyui-combobox" style="width:160px;" data-options=" valueField: 'zhixingbiaozhun',
                    textField: 'zhixingbiaozhun'"><br><span style="font-size: 12px;color: red;"
                                                            id="zhixingbiaozhuntest"></span></td>
            </tr>
            <tr>
                <td align="right">里料：</td>
                <td><input id="liliao" class="easyui-textbox" style="width:160px;" data-options="multiline:true"></td>
                <td align="right">面料：</td>
                <td><input id="mianliao" class="easyui-textbox" style="width:160px;" data-options="multiline:true"></td>
            </tr>
            <tr>
            </tr>
            <tr>
                <td align="right">撞料：</td>
                <td><input id="zhuangliao" class="easyui-textbox" style="width:160px;" data-options="multiline:true">
                </td>
                <td align="right">填充物：</td>
                <td><input id="tianchongwu" class="easyui-textbox" style="width:160px;" data-options="multiline:true">
                </td>
            </tr>
            <tr>
                <td align="right">胆布：</td>
                <td><input id="danbu" class="easyui-textbox" style="width:160px;" data-options="multiline:true">
                </td>
                <td align="right">备注：</td>
                <td><input id="beizhu" class="easyui-textbox" style="width:160px;" data-options="multiline:true">
                </td>
            </tr>
        </table>
        <div class="easyui-tabs" style="/*width:700px;height:250px*/">
            <div title="颜色" style="padding:10px">
                <table>
                    <tr>
                        <td><input class="easyui-textbox color" style="width: 80px"></td>
                        <td>
                            <a href="#" class="easyui-linkbutton" plain="true" onclick="addYanse()" iconCls="icon-add">再添加一个颜色</a>
                        </td>
                    </tr>
                    <tr>
                        <td><input class="easyui-textbox color" style="width: 80px"></td>
                    </tr>
                    <tr>
                        <td><input class="easyui-textbox color" style="width: 80px"></td>
                    </tr>
                    <tbody id="yansezu">


                    </tbody>
                </table>


            </div>
            <div title="尺码" style="padding:10px">
                <table>
                    <tr>
                        <td><input class="easyui-textbox size" style="width: 80px"></td>
                        <td>
                            <a href="#" class="easyui-linkbutton" plain="true" onclick="addChima()" iconCls="icon-add">再添加一个尺码</a>
                        </td>
                    </tr>
                    <tr>
                        <td><input class="easyui-textbox size" style="width: 80px"></td>
                    </tr>
                    <tr>
                        <td><input class="easyui-textbox size" style="width: 80px"></td>
                    </tr>
                    <tr>
                        <td><input class="easyui-textbox size" style="width: 80px"></td>
                    </tr>
                    <tr>
                        <td><input class="easyui-textbox size" style="width: 80px"></td>
                    </tr>

                    <tbody id="chimazu">


                    </tbody>
                </table>

            </div>
        </div>
        <div id="bb">
            <button onclick="save()"
                    class="easyui-linkbutton" data-options="iconCls:'icon-save' ">保存
            </button>
            <button onclick="$('#addwindow').window('close')"
                    class="easyui-linkbutton" data-options="iconCls:'icon-no'">取消
            </button>
        </div>
    </div>
        <%--下级新增窗口--%>
    <div id="downwindow" style="padding: 15px" class="easyui-dialog"
         data-options="buttons:'#ba', modal:true,closed:true,collapsible:false,iconCls:'icon-save',minimizable:false,maximizable:false">
        <input type="hidden" id="downid">
        <table>
            <tr>
                <td align="right">商品编号：<span style="color: red">*</span></td>
                <td align="left"><input id="shangpinbianhao" class="easyui-textbox" style="width:160px;"
                                        data-options="prompt:'请输入商品编号'"><br><span style="font-size: 12px;color: red;"
                                                                                  id="shangpinbianhaotest"></span>
                </td>
                <td align="right">款名：<span style="color: red">*</span></td>
                <td align="left"><input id="downkuanming" class="easyui-textbox" style="width:160px;"
                                        data-options="prompt:'请输入款名称'"><br><span style="font-size: 12px;color: red;"
                                                                                 id="downkuanmingtest"></span>
                </td>
            </tr>
            <tr>
                <td align="right">铭牌价：<span style="color: red">*</span></td>
                <td><input id="downmingpaijia" class="easyui-numberbox" style="width:160px;" type="text"
                           precision="2"
                           data-options="min:0,prompt:'请输入铭牌价格'"><br><span style="font-size: 12px;color: red;"
                                                                           id="downmingpaijiatest"></span></td>
                <td align="right">性别：</td>
                <td><select id="downxingbie" class="easyui-combobox" data-options="panelHeight:'auto'" editable="false"
                            style="width:160px;">
                    <option>男</option>
                    <option>女</option>
                    <option>中性</option>
                </select><br><span style="font-size: 12px;color: red;"
                                   id="downxingbietest"></span></td>
            </tr>

            <tr>
                <td align="right">年份：</td>
                <td><select id="downyear" class="easyui-combobox" panelHeight="auto" editable="false"
                            style="width:160px;">
                    <option>2015</option>
                    <option>2016</option>
                    <option>2017</option>
                    <option>2018</option>
                    <option>2019</option>
                    <option>2020</option>
                </select>
                </td>
                <td align="right">季节：</td>
                <td><select id="downjijie" class="easyui-combobox" style="width:160px;" editable="false">
                    <option>春季</option>
                    <option>夏季</option>
                    <option>秋季</option>
                    <option>冬季</option>
                </select><br><span style="font-size: 12px;color: red;"
                                   id="downjijietest"></span></td>
            </tr>
            <tr>
                <td align="right">颜色：<span style="color: red">*</span></td>
                <td><input id="downcolor" class="easyui-textbox"
                           style="width:160px;"/><br><span
                        style="font-size: 12px;color: red;"
                        id="downcolortest"></span></td>
                </td>
                <td align="right">尺码：<span style="color: red">*</span></td>
                <td><input id="downsize" class="easyui-textbox" style="width:160px;"/><br><span
                        style="font-size: 12px;color: red;"
                        id="downsizetest"></span></td>
            </tr>
        </table>

        <div id="ba">
            <button onclick="saveDown()"
                    class="easyui-linkbutton" data-options="iconCls:'icon-save' ">保存
            </button>
            <button onclick="$('#downwindow').window('close')"
                    class="easyui-linkbutton" data-options="iconCls:'icon-no'">取消
            </button>
        </div>
    </div>
    <input id="jgid" value="<%=request.getParameter("jgid")%>">
    </body>

    <script type="text/javascript">
        if ($("#jgid").val() == 1) {
            $("#zongbu").show();
            $("#zongbuxiugai").show();
            $("#xiaji").hide();
            $("#xiajixiugai").hide();
        } else {
            $("#xiaji").show();
            $("#xiajixiugai").show();
            $("#zongbu").hide();
            $("#zongbuxiugai").hide();
        }


        //验证款号输入框是否正确
        $('#kuanhao').textbox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var kuanhao = this.value;
                    if (kuanhao == "" || kuanhao == null) {
                        $("#kuanhaotest").text("*请输入款号");
                        return;
                    }
                    var id = $('#id').val();
                    $.ajax({
                        url: path + '/production/find/kuanhao.do',
                        dataType: 'json',
                        type: 'POST',
                        data: {
                            product: kuanhao,
                            id: id
                        },
                        success: function (data) {
                            if (data.code == 400) {
                                $("#kuanhaotest").text("*已存在该款号")
                            } else {
                                $("#kuanhaotest").text("");
                            }
                        }
                    })
                }
            }
        });
        //验证款号输入框是否正确
        $('#shangpinbianhao').textbox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var kuanhao = this.value;
                    if (kuanhao == "" || kuanhao == null) {
                        $("#kuanhaotest").text("*请输入款号");
                        return;
                    }
                    var id = $("#downid").val();
                    $.ajax({
                        url: path + '/production/find/kuanhao.do',
                        dataType: 'json',
                        type: 'POST',
                        data: {
                            product: kuanhao,
                            id: id
                        },
                        success: function (data) {
                            if (data.code == 400) {
                                $("#shangpinbianhaotest").text("*已存在该款号")
                            } else {
                                $("#shangpinbianhaotest").text("");
                            }
                        }
                    })
                }
            }
        });
        //验证款名是否为空
        $('#kuanming').textbox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var kuanming = this.value;
                    if (kuanming == "" || kuanming == null) {
                        $("#kuanmingtest").text("*款名不能为空");
                        return;
                    } else {
                        $("#kuanmingtest").text("");
                    }
                }
            }
        });
        //验证价格是否为空
        $('#mingpaijia').numberbox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var mingpaijia = this.value;
                    if (mingpaijia == "" || mingpaijia == null) {
                        $("#mingpaijiatest").text("铭牌价不能为空");
                        return;
                    } else if (mingpaijia < 0) {
                        $("#mingpaijiatest").text("*铭牌价不能小于0");
                        return;
                    } else {
                        $("#mingpaijiatest").text("")
                    }
                }
            }
        });
        //款式
        $('#kuanshi').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var kuanshi = this.value;
                    if (kuanshi == "" || kuanshi == null) {
                        $("#kuanshitest").text("*款式不能为空");
                        return;
                    } else {
                        $("#kuanshitest").text("");
                    }
                }
            },
            onSelect: function (param) {
                if (param == "" || param == null) {
                    $("#kuanshitest").text("*款式不能为空");
                    return;
                } else {
                    $("#kuanshitest").text("");
                }
            }
        });
        //款式
        $('#pinpai').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var pinpai = this.value;
                    if (pinpai == "" || pinpai == null) {
                        $("#pinpaitest").text("*品牌不能为空");
                        return;
                    } else {
                        $("#pinpaitest").text("");
                    }
                }
            },
            onSelect: function (param) {
                if (param == "" || param == null) {
                    $("#pinpaitest").text("*品牌不能为空");
                    return;
                } else {
                    $("#pinpaitest").text("");
                }
            }
        });
        //款型
        $('#kuanxing').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var style = this.value;
                    if (style == "" || style == null) {
                        $("#kuanxingtest").text("*款型不能为空");
                        return;
                    } else {
                        $("#kuanxingtest").text("");
                    }
                }
            },
            onSelect: function (param) {
                if (param == "" || param == null) {
                    $("#kuanxingtest").text("*款型不能为空");
                    return;
                } else {
                    $("#kuanxingtest").text("");
                }
            }
        });
        //大类
        $('#dalei').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var dalei = this.value;
                    if (dalei == "" || dalei == null) {
                        $("#daleitest").text("*大类不能为空");
                        return;
                    } else {
                        $("#daleitest").text("");
                    }
                }
            },
            onSelect: function (param) {
                if (param == "" || param == null) {
                    $("#daleitest").text("*大类不能为空");
                    return;
                } else {
                    $("#daleitest").text("");
                }
            }
        });
        //小类
        $('#xiaolei').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var xiaolei = this.value;
                    if (xiaolei == "" || xiaolei == null) {
                        $("#xiaoleitest").text("*小类不能为空");
                        return;
                    } else {
                        $("#xiaoleitest").text("");
                    }
                }
            },
            onSelect: function (param) {
                if (param == "" || param == null) {
                    $("#xiaoleitest").text("*小类不能为空");
                    return;
                } else {
                    $("#xiaoleitest").text("");
                }
            }
        });
        //供应商
        $('#gongyings').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var gongyingshang = this.value;
                    if (gongyingshang == "" || gongyingshang == null) {
                        $("#gongyingstest").text("*供应商不能为空");
                        return;
                    } else {
                        $("#gongyingstest").text("");
                    }
                }
            },
            onSelect: function (param) {
                if (param == "" || param == null) {
                    $("#gongyingstest").text("*供应商不能为空");
                    return;
                } else {
                    $("#gongyingstest").text("");
                }
            }
        });
        //性别
        $('#xingbie').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var xingbie = this.value;
                    if (xingbie == "" || xingbie == null) {
                        $("#xingbietest").text("*性别不能为空");
                        return;
                    } else {
                        $("#xingbietest").text("");
                    }
                }
            },
            onSelect: function (param) {
                if (param == "" || param == null) {
                    $("#xingbietest").text("*性别不能为空");
                    return;
                } else {
                    $("#xingbietest").text("");
                }
            }
        });
        //季节
        $('#jijie').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var season = this.value;
                    if (season == "" || season == null) {
                        $("#jijietest").text("*季节不能为空");
                        return;
                    } else {
                        $("#jijietest").text("");
                    }
                },
                onSelect: function (param) {
                    if (param == "" || param == null) {
                        $("#jijietest").text("*季节不能为空");
                        return;
                    } else {
                        $("#jijietest").text("");
                    }
                }
            }
        });
        //季节
        $('#anquanjibie').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var anquanjibie = this.value;
                    if (anquanjibie == "" || anquanjibie == null) {
                        $("#anquanjibietest").text("*安全级别不能为空");
                        return;
                    } else {
                        $("#anquanjibietest").text("");
                    }
                }
            },
            onSelect: function (param) {
                if (param == "" || param == null) {
                    $("#anquanjibietest").text("*安全级别不能为空");
                    return;
                } else {
                    $("#anquanjibietest").text("");
                }
            }
        });
        //执行标准
        $('#zhixingbiaozhun').combobox({
            events: {
                blur: function () {
                    //由于获取是上一次的值 所有这里有this.value
                    var zhixingbiaozhun = this.value;
                    if (zhixingbiaozhun == "" || zhixingbiaozhun == null) {
                        $("#zhixingbiaozhuntest").text("*执行标准不能为空");
                        return;
                    } else {
                        $("#zhixingbiaozhuntest").text("");
                    }
                }
            },
            onSelect: function (param) {
                if (param == "" || param == null) {
                    $("#zhixingbiaozhuntest").text("*执行标准不能为空");
                    return;
                } else {
                    $("#zhixingbiaozhuntest").text("");
                }
            }
        });


        $("#dg").datagrid({
            url: path + '/production/findall.do'
        });
        $("#dg").datagrid({
            method: 'GET',
            striped: true,
            rownumbers: false,
            singleSelect: true,
            toolbar: '#tb',
            checkbox: false,
            fit: true,
            striped: true,
            fitColumns: false,
            autoRowHeight: false,
            rownumbers: true,
            pagination: true,
            pageSize: 20,
            pageList: [20, 30, 50],
            nowrap: true,
            loadMsg: '加载中,请稍后......',
            columns: [[{
                field: 'id',
                title: '类别',
                width: 80,
                hidden: true
            }, {
                field: 'product',
                title: '商品款号',
                width: 150,
                align: 'center'
            }, {
                field: 'productName',
                title: '商品名',
                width: 80,
                align: 'center'
            }, {
                field: 'state',
                title: '商品状态',
                width: 80,
                align: 'center',
                formatter: function (value, row, index) {
                    if (value == 0) {
                        return '生效'
                    } else if (value == 1) {
                        return '停用'
                    }
                },
                styler: function (value, row, index) {
                    if (value == 0) {
                        return 'color:green'
                    } else if (value == 1) {
                        return 'color:red'
                    }
                }
            }, {
                field: 'colors',
                title: '颜色组',
                width: 130,
                align: 'right',
                formatter: function (value, row, index) {
                    if (value != null) {
                        value = value.substring(1, value.length - 1);
                        return value;
                    }
                }
            }, {
                field: 'sizes',
                title: '尺码组',
                width: 250,
                align: 'right',
                formatter: function (value, row, index) {
                    if (value != null) {
                        value = value.substring(1, value.length - 1);
                        return value;
                    }
                }
            }, {
                field: 'price',
                title: '铭牌价',
                width: 80,
                align: 'right',
                formatter: function (value, row, index) {
                    if (value != null) {
                        return value.toFixed(2);
                    }
                }
            }, {
                field: 'sex',
                title: '性别',
                width: 80,
                align: 'center'
            }, {
                field: 'mianliao',
                title: '商品面料',
                width: 160,
                align: 'center'
            }, {
                field: 'kuanshi',
                title: '商品款式',
                width: 80,
                align: 'center'
            }, {
                field: 'pinpai',
                title: '商品品牌',
                width: 80,
                align: 'center'
            }, {
                field: 'gname',
                title: '供应商',
                width: 120,
                align: 'center'
            }, {
                field: 'year',
                title: '商品年份',
                width: 80,
                align: 'center'
            }, {
                field: 'style',
                title: '商品款型',
                width: 80,
                align: 'center'
            }, {
                field: 'season',
                title: '商品季节',
                width: 80,
                align: 'center'
            }, {
                field: 'danbu',
                title: '胆布',
                width: 160,
                align: 'center'
            }, {
                field: 'beizhu',
                title: '备注',
                width: 200,
                align: 'center'
            }]],
            //loadFilter : function(responseData) {
            //	return responseData.data;
            //},
            onBeforeLoad: function (param) {
                var jgid = $("#jgid").val();
                if (jgid == 1) {
                    $("#dg").datagrid('showColumn', 'mianliao');
                    $("#dg").datagrid('showColumn', 'kuanshi');
                    $("#dg").datagrid('showColumn', 'pinpai');
                    $("#dg").datagrid('showColumn', 'gname');
                    $("#dg").datagrid('showColumn', 'style');
                    $("#dg").datagrid('showColumn', 'danbu');
                    $("#dg").datagrid('showColumn', 'beizhu');
                } else {
                    $("#dg").datagrid('hideColumn', 'mianliao');
                    $("#dg").datagrid('hideColumn', 'kuanshi');
                    $("#dg").datagrid('hideColumn', 'pinpai');
                    $("#dg").datagrid('hideColumn', 'gname');
                    $("#dg").datagrid('hideColumn', 'style');
                    $("#dg").datagrid('hideColumn', 'danbu');
                    $("#dg").datagrid('hideColumn', 'beizhu');
                }
            },
            onLoadSuccess: function (data) {
                $("#ss").next().find("input").eq(0).focus();
            },
            onLoadError: function () {
                //	console.debug('not ok')
            }
        });
        //停用产品
        function tingyong(state) {
            var mes = '';
            if (state == 0) {
                mes = '恢复';
            } else {
                mes = '停用';
            }
            var row = $('#dg').datagrid('getSelected');
            if (row) {
                if (row.state == state) {
                    $.messager.show({
                        title: '提示',
                        msg: row.product + '已是该状态，请确认数据后刷新重试！',
                        timeout: 3000,
                        showType: 'slide'
                    });
                    return;
                }
                $.messager.confirm('Confirm', '是否确认' + mes + row.product + '?', function (r) {
                    if (r) {
                        $.ajax({
                            url: path + '/production/update/state.do',
                            dataType: 'json',
                            type: 'POST',
                            data: {
                                id: row.id,
                                state: state
                            },
                            success: function (data) {
                                if (data.code == 200) {
                                    $.messager.show({
                                        title: '提示',
                                        msg: mes + row.product + '成功!',
                                        timeout: 3000,
                                        showType: 'slide'
                                    });
                                    $("#dg").datagrid({
                                        url: path + '/production/findall.do'
                                    });
                                } else {
                                    $.messager.alert('提示', data.msg);
                                }
                            }
                        })
                    }
                });
            } else {
                $.messager.alert('提示', '请选择要操作的数据');
            }
        }

        //供应商combobox加载
        $('#gongyingshang').combobox({
            url: path + '/gongyingshang/list/combobox.do',
            valueField: 'id',
            textField: 'gname',
            onLoadError: function () {
                $.messager.alert('警告', '供应商数据加载失败!');
            },
            onLoadSuccess: function () { //默认选中第一条数据
                var data = $(this).combobox("getData");
                if (data.length > 0) {
                    $('#gongyingshang').combobox('select', data[0].id);
                }
            }
        });


    </script>
</shiro:hasPermission>
